﻿@using ZBJF.Warranty.Common.Enums.InsuranceOrder
@using ZBJF.Warranty.WebProvider

@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("ImportQuotationList", "InsuranceWarrantyRecord", FormMethod.Post, new { id = "importQuotationListForm", name = "importQuotationListForm", @class = "breadcrumb form-search", enctype = "multipart/form-data" }))
{

    <table>
        <tr>
            <td>
                <label>选择文件:</label>
            </td>
            <td>
                <span class="showFileName"></span>
                <a href="javascript:void(0)" class="file">
                    选择文件
                    <input type="file" name="importFile" validate="{required:true,messages:{required:'请先选择要上传的文件'}}" />
                </a>
                <input id="btnSubmit" class="btn btn-primary Import-R" type="submit" value="上传文件">
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
        </tr>
    </table>
}
@if (!string.IsNullOrEmpty(ViewBag.ReturnInfo != null ? ViewBag.ReturnInfo.ToString() : string.Empty))
{
    <div style="margin-left: 50px;">
        <h3>导入结果</h3>
        @Html.Raw(ViewBag.ReturnInfo)
    </div>
}
@section scripts{
    <script type="text/javascript">
    $(function() {
        $(".file").on("change", "input[type='file']", function() {
            var filePath = $(this).val();
            if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
                var arr = filePath.split('\\');
                var fileName = arr[arr.length - 1];
                $(".showFileName").html(fileName).removeClass("red");
            } else {
                $(".showFileName").html("请选择Excel文件").addClass("red");
                return;
            }
        });
        $("#importQuotationListForm").submit(function () {
            if ($(this).valid()) {
                if ($(".showFileName").hasClass("red")) {
                    layer.alert("请选择Excel文件");
                    return false;
                }
                layer.load();
                return true;
            }
            return false;
        });
    })
    </script>
}